using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using ClickSocial.Framework;

namespace ClickSocial
{
    public partial class Contacto : CDefault 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMensaje.Visible = false;                
        }

        protected void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage correo = new MailMessage();

                foreach (string userhost in Roles.GetUsersInRole(Global.RolesApp.Host))
                {
                    MembershipUser user = Membership.GetUser(userhost);
                    correo.To.Add(user.Email);
                }
                correo.From = new MailAddress(txtDe.Text);
                correo.Subject = "ClickSocial Consulta: " + txtAsunto.Text;
                correo.Body = txtConsulta.Text;
                correo.IsBodyHtml = false;
                correo.Priority = System.Net.Mail.MailPriority.Normal;

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.Send(correo);

                txtAsunto.Text = string.Empty;
                txtDe.Text = string.Empty;
                txtConsulta.Text = string.Empty;

                lblMensaje.Visible = true;
                lblMensaje.Text = "La consulta ha sido enviada con exito!";

            }
            catch 
            {
                lblMensaje.Visible = true;
                lblMensaje.Text = "Ha ocurrido un error durante el envio, pruebe mas tarde por favor y disculpe las molestias.!";
            }

        }
    }
}
